<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>充值中心</title>
<link rel="stylesheet" href="${base}/static/media/css/bootstrap.css" />
<script src="${base}/static/index/vendor/jquery/jquery.min.js"></script>
<script src="${base}/static/index/vendor/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" charset="utf-8"
	src="${base }/static/vendor/bootstrapPager/bootstrapPager.js"></script>
<script type="text/javascript" charset="utf-8"
	src="${base }/static/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" charset="utf-8" src="${base }/static/js/layer/layer.js"></script>
<link href="${base }/static/css/base.css" rel="stylesheet"
	type="text/css" />
<link rel="stylesheet" type="text/css"
	href="${base }/static/css/help.css" />
<script type="text/javascript"
	src="${base }/static/js/jquery-1.8.1.min.js"></script>
<script type="text/javascript">
function smalltoBIG(n)     
{    
    var fraction = ['角', '分'];    
    var digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];    
    var unit = [ ['元', '万', '亿'], ['', '拾', '佰', '仟']  ];    
    var head = n < 0? '欠': '';    
    n = Math.abs(n);    
  
    var s = '';    
  
    for (var i = 0; i < fraction.length; i++)     
    {    
        s += (digit[Math.floor(n * 10 * Math.pow(10, i)) % 10] + fraction[i]).replace(/零./, '');    
    }    
    s = s || '整';    
    n = Math.floor(n);    
  
    for (var i = 0; i < unit[0].length && n > 0; i++)     
    {    
        var p = '';    
        for (var j = 0; j < unit[1].length && n > 0; j++)     
        {    
            p = digit[n % 10] + unit[1][j] + p;    
            n = Math.floor(n / 10);    
        }    
        s = p.replace(/(零.)*零$/, '').replace(/^$/, '零')  + unit[0][i] + s;    
    }    
    return head + s.replace(/(零.)*零元/, '元').replace(/(零.)+/g, '零').replace(/^整$/, '零元整');    
}
function changeY(){
	
	var totalAssets = $("input[name=totalAssets]").val();
	
	
	
	var data = smalltoBIG(totalAssets);
	$("#showRMB").text(data);
	$("#showRMB").show();
}
$(document).ready(function(){
	$("#submitButton").click(function(){
		var phone = $("input[name=phone]").val();
		var totalAssets = $("input[name=totalAssets]").val();
		var businessId = $("input[name=businessId]").val();
		var isCheck = true;
		if(phone==''){
			layer.msg("请输入账号");
			isCheck = false;
			return false;
		}
		if(totalAssets==''){
			layer.msg("请输入金额");
			isCheck = false;
			return false;
		}
		if(!$.isNumeric(totalAssets)){
			layer.msg('金额格式错误');
			isCheck = false;
			return false;
		}
		if(isCheck==true){
			layer.confirm('确定要给该账号充值吗?', {icon: 3, title:'提示'}, function(index){
				layer.close(index);
				$("#submitButton").hide();
				$("#submitShow").show();
				$.ajax({
		        	url:"${base}/admin/sumRecharger",
		            type:'post',
		            dataType:'json',
		            data:{"businessId":businessId,"totalAssets":totalAssets,"phone":phone},
		            success:function(res)
		            {
		                if(res.code==1){
		                	layer.alert('充值成功', {icon: 1});
		                }else if(res.code==0){
		                	layer.alert('充值失败', {icon: 1});
		                }
		                $("#submitButton").show();
						$("#submitShow").hide();
		            }
		        });
		        return false;
			});
		}
	});
});
</script>

<script type="text/javascript">
	function submit1(){
		var businessPhone = '${businessUser.phone}';
		
		//对比输入的账号是否相同，不相同就退出
		
		//否则就提交 
	}
</script>
</head>
<body style="background:#fff;">
	<div class="portlet-body">
		<form class="dataform" id="orderlist_form"
			action=""
			method="post">
			<input type="hidden" name="businessId" value="${businessUser.id}"> 
			<div class="row">
				<label class="col-md-1" style="line-height:35px;">姓名：</label>
				<div class="col-md-2">
					${businessUser.nickname }
				</div>
			</div>
			<div class="row">
				<label class="col-md-1" style="line-height:35px;">账号：</label>
				<div class="col-md-2">
					<input type="text" class="form-control" name="phone"
						placeholder="请输入充值账号" value="" id="">
				</div>
			</div>
			<div class="row" style="height:15px;"></div>
			<div class="row">
				<label class="col-md-1" style="line-height:35px;">金额：</label>
				<div class="col-md-2">
					<input type="text" class="form-control" name="totalAssets"
						placeholder="请输入充值金额" value="" oninput="changeY()" id="">
				</div>
				<label class="col-md-3" style="display:none;line-height:35px;" id="showRMB">
					
				</label>
			</div>
			<div class="row" style="">
				
				<div style="width:14%;height: 30px;display: inline-block;margin-left:10%;margin-top:20px;">
					<input type="button" class="btn offline_serch_hide"
						style="margin-right: 30px; background: #18BC9C; color: #fff; border-color: #18BC9C;"
						value="充值" id="submitButton">
					<input type="button" class="btn offline_serch_hide"
						style="margin-right: 30px; background: #999; color: #fff; border-color: #999;display:none;"
						value="充值中。。。" disabled="disabled" id="submitShow">
				</div>
			</div>
			<div style="width: 100%; height: 15px;"></div>
		</form>
	</div>
</body>
</html>